package com.lry.dao;

import java.sql.JDBCType;

import com.lry.bean.User;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 
 *
 * @author 李瑞益
 * @date 2019/8/20
 */
public interface UserMapper {

    @Select({
        "select uid,name,password,salt,username from user where state = 0 and name = #{name , jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column = "uid",property = "id",jdbcType = JdbcType.INTEGER),
            @Result(column = "name",property = "name",jdbcType = JdbcType.NVARCHAR),
            @Result(column = "password",property = "password",jdbcType = JdbcType.NVARCHAR),
            @Result(column = "username",property = "userName",jdbcType = JdbcType.NVARCHAR),
            @Result(column = "salt",property = "salt",jdbcType = JdbcType.VARCHAR)
    })
    User getByName(String name);

    @InsertProvider(type = UserSqlProvider.class,method = "addUser")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="uid")
    int addUser(User user);
}
